/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.xwamp.webutil;

import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author SoChishun
 */
public class WebRuntimeUtil {

    public static WebRuntimeUtil me = new WebRuntimeUtil();

    // example getCanonicalPath("runtime/tmp/excel/admin.xls")
    public String getCanonicalPath(String path) {
        try {
            File file = new File(path);
            if (!file.exists()) {
                file.getParentFile().mkdirs();
            }
            return file.getCanonicalPath();
        } catch (IOException ex) {
            Logger.getLogger(WebRuntimeUtil.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
        //String path = PathKit.getWebRootPath() + File.separator + "runtime" + File.separator + "Public" + File.separator  + "DateFile" + File.separator + "WIP.xls";
    }
    /**
     * 获取有效的地址
     * @param filePath
     * @return 
     * @since 1.0 2017-5-26
     */
    public boolean existsFile(String filePath){
        File file=new File(filePath);
        return file.exists();
    }
}
